// 파일트리  Grid
var httpProxyFilePath = new Ext.data.HttpProxy({
	method: 'POST',
	url: '',
	timeout: 90000
});

var readerFilePath = new Ext.data.JsonReader({
	root: 'json_list',
	totalProperty: 'json_count',
	fields: [
		'file_no', 'depth', 'depth_idx', 'file_path', 'file_name', 'detect_count', 'cnt', 'cnt_type'
	]
});

var gstoreFilePath = new Ext.data.GroupingStore({
	reader: readerFilePath,
	sortInfo: {field: 'depth', direction: "DESC"},
	groupField: 'file_path',
	//autoLoad: true,
	proxy: httpProxyFilePath
});

function fnRdrFile(val, metadata, record, rowIndex, colIndex, store)
{
	var strRet = '';
	
	var cnt_type = record.data.cnt_type;
	var cnt = record.data.cnt;
	
	if(cnt_type == 'Y')
	{
		if(cnt == '0')
		{
			strRet = val + '(' + cnt + ')';
		}
		else
		{
			strRet = '<font color="red">' + val + '(' + cnt + ')</font>';
		}
	}
	else
	{
		strRet = val;
	}
	
	return strRet;
}

var columnModelFilePath = new Ext.grid.ColumnModel([
	{
		id: 'depth',
		header: 'depth',
		dataIndex: 'depth',
		hidden: true
	},{
		id: 'depth_idx',
		header: 'depth_idx',
		dataIndex: 'depth_idx',
		hidden: true
	},{
		id: 'file_path',
		header: 'file_path',
		dataIndex: 'file_path',
		hidden: true
	},{
		id: 'file_name',
		header: '파일명',
		dataIndex: 'file_name',
		sortable: true,
		width: 380,
		renderer: fnRdrFile
	}
]);
		
var gridFilePath = new Ext.grid.GridPanel({
	region: 'center',
	id: 'id_grid_file_path',
	name: 'grid_file_path',
	title: m_RootText,
	store: gstoreFilePath,
	cm: columnModelFilePath,
	sm: new Ext.grid.RowSelectionModel(),
	border: true,
	autoScroll: true,
	loadMask: true,
	stripeRows: true,
	autoWidth: true,
	view: new Ext.grid.GroupingView({
       // startCollapsed: true,
       groupTextTpl: '{[values.rs[0].data["file_path"]]}'
    })
});


Ext.getCmp('id_grid_file_path').selModel.on('rowselect', function(sm, rowIdx, r) {
	if (m_RootType == '2')
	{
		var strFileNo = r.data.file_no;
		var strFileName = r.data.file_name;
		var strCnt = r.data.cnt;
		
		if(strCnt == '0')
		{
			alert('검출된 내역이 존재하지 않습니다.');
		}
		else
		{
			top.frameContents.location.href = m_ContextName + '/analysis/analysis600Main.do?fileNo=' + strFileNo;
		}
	}
});





















	
	
	
	